<template>
  <!-- 未完成订单头部组件 -->
  <div>
    <div class="header_title">
      <div style="flex: 1;" />
      <div style="flex: 4;">
        <slot name="center">
          <div class="btns">
            <div :class="!active ? 'active' : ''"
                 @click="changeTab(1)">外卖配送</div>
            <div :class="active ? 'active' : ''"
                 @click="changeTab(2)">到店自取</div>
          </div>
        </slot>
      </div>
      <div style="flex: 1;">
        <slot name="right">
          <van-icon class="H_right"
                    @click="searchOrder"
                    name="search" />
        </slot>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  data () {
    return {
      active: true,
    }
  },
  props: ['sonChange'],
  components: {
  },
  methods: {
    // 状态改变
    changeTab (index) {
      if (index == 1) {
        this.active = true
        this.$emit('sonChange', '1')
      } else {
        this.active = false
        this.$emit('sonChange', '2')
      }
    },
    searchOrder () {
      this.$router.push('/searchOrder')
    }
  }
}
</script>

<style scoped lang="scss">
.header_title {
  background-color: rgba(255, 110, 83, 1);
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 50px;
  font-size: 16px;
  color: aliceblue;
}

.changeTab {
  width: 40%;
  margin: 0 auto;
  border-radius: 20px;
}
.btns {
  display: flex;
  // outline: red solid;
  justify-content: center;
  // margin-left: 8px;
  div {
    width: 80px;
    height: 30px;
    line-height: 30px;
    background-color: #fff;
    color: #ff6e53;
    text-align: center;
    font-size: 14px;
  }
  div:first-child {
    border-radius: 20px 0 0 20px;
  }
  div:last-child {
    border-radius: 0 20px 20px 0;
  }
  .active {
    background-color: #fca190;
    color: #fff;
  }
}
.van-icon-search:before {
  font-size: 18px;
}
.H_right {
  display: flex;
  flex-direction: row-reverse;
  margin-right: 15px;
}
</style>
